package org.xmatch.framework.exception;

import org.jboss.seam.core.Interpolator;


public class GenericException extends Exception {

	private static final long serialVersionUID = 6563337496412181831L;

	private Object[] messageParameters;

	private String convertedMessage;


	public GenericException() {
		super();
	}

	
	public GenericException(String message, Throwable cause) {
		super(message, cause);
	}

	
	public GenericException(String message) {
		super(message);
	}

	
	public GenericException(Throwable cause) {
		super(cause);
	}

	
	public GenericException(String message, Throwable cause, Object... parameters) {
		super(message, cause);
		this.messageParameters = parameters;
	}

	
	public GenericException(String message, Object... parameters) {
		super(message);
		this.messageParameters = parameters;
	}

	public Object[] getMessageParameters() {
		return messageParameters;
	}

	public void setMessageParameters(Object... parameters) {
		this.messageParameters = parameters;
		this.convertedMessage = null;
	}

	@Override
	public String getMessage() {
		if (messageParameters != null && super.getMessage() != null) {
			if (convertedMessage == null) {
				convertedMessage = Interpolator.instance().interpolate(
						super.getMessage(), messageParameters);
			}
			return convertedMessage;
		}
		return super.getMessage();
	}
}
